package com.practice.xml;

import java.util.ArrayList;
import java.util.List;

public class XmlPractice {

	public static void main(String[] args) {
		XmlProcessor processor;

		Company company = new Company();
		company.setName("Cosmos");
		List<Employee> employees = new ArrayList<>();
		company.setEmployees(employees);

		Employee employee;
		employee = new Employee();
		employee.setName("Leo");
		employee.setSex(true);
		employee.setAge(20);
		employees.add(employee);
		
		employee = new Employee();
		employee.setName("Lex");
		employee.setSex(true);
		employee.setAge(30);
		employees.add(employee);

		processor = new com.practice.xml.jaxb.JaxbXmlProcessor();
		processor.createXml(company, "company.xml");
		company = processor.parseXml("company.xml");

		if (company == null) {
			return;
		}
		System.out.println(company.getName());
		employees = company.getEmployees();
		if (employees == null) {
			return;
		}
		for (Employee emp : employees) {
			System.out.println(emp.getName());
			System.out.println(emp.getSex());
			System.out.println(emp.getAge());
		}
	}

}
